<?php
$this->breadcrumbs = array(
	'材料单据列表' => array(
		'index'
	),
	$model->project->name . ' (' . $model->receiptDate . ')',
);
if (Yii::app()->user->checkAccess('materialReceiptManage')) {
	$this->userActions = array(
		//array('label'=>'List MaterialReceipt', 'url'=>array('index')),
		array(
			'label' => '新建材料单据',
			'url' => array(
				'create'
			)
		),
		array(
			'label' => '更新材料单据',
			'url' => array(
				'update',
				'id' => $model->id
			)
		),
		array(
			'label' => '删除材料单据',
			'url' => '#',
			'linkOptions' => array(
				'submit' => array(
					'delete',
					'id' => $model->id
				),
				'confirm' => 'Are you sure you want to delete this item?'
			)
		),
		array(
			'label' => '管理材料单据',
			'url' => array(
				'admin'
			)
		),
		array(
			'label' => '管理 ' . $model->itemCount . ' 物品',
			'url' => array(
				'updateItems',
				'id' => $model->id
			),
			'iconClass' => 'icon-basket',
		),
	);
}
?>

<h1>查看单据 <?php echo $model->project->name . ' (' . $model->receiptDate . ') #' . $model->token; ?></h1>
<div class="span-2"><?php echo CHtml::link(CHtml::encode($model->receiptDate),
						array(
							'view',
							'id' => $model->id
						), array(
							'target' => '_blank'
						));
					?></div>

<div class="span-3"><?php echo CHtml::encode($model->project->name); ?></div>
<div class="span-3">
	<?php echo CHtml::encode($model->getAttributeLabel('handler')); ?>:
	<?php echo CHtml::encode($model->handler); ?>
</div>
<div class="span-3">
	<?php echo CHtml::encode($model->getAttributeLabel('type')); ?>:
	<?php echo CHtml::encode($model->displayType); ?>
</div>
<div class="span-4">
	<?php echo CHtml::encode($model->getAttributeLabel('token')); ?>:
	<?php echo CHtml::encode($model->token); ?>
</div>
<div class="span-4 last">

	共 <?php echo CHtml::encode($model->itemCount); ?> 项物品
</div>
<div class="clear"></div>
<div class="span-11">
	<?php echo CHtml::encode($model->getAttributeLabel('merchantId')); ?>:
	<?php if ($model->merchant) {
			echo CHtml::encode($model->merchant->name);
		}
	?>
</div>
<div class="span-4">
	<?php echo CHtml::encode($model->getAttributeLabel('warehouseManagerId')); ?>:
	<?php echo CHtml::encode($model->warehouseManager->fullName); ?>
</div>
<div class="span-3 last">
	<?php echo CHtml::encode($model->getAttributeLabel('priceCheckable')); ?>:
	<?php $booleans=JHTML::getBooleanValues(); echo $booleans[$model->priceCheckable]; ?>
</div>
<div class="clear"></div>
<?php if ($model->note) { ?>
<div><?php echo CHtml::encode($model->getAttributeLabel('note')); ?>:
	<?php echo CHtml::encode($model->note); ?></div>
<?php } ?>
<?php if ($model->itemCount > 0) { ?>
<div class="item-list-grid">
<?php
	$this->renderPartial('_itemList', array(
			'items' => $model->items
		));
?>
</div>
<div class="clear"></div>
<?php } ?>
<div>
<div class="span-3">物品总价:
	<?php echo Yii::app()->format->formatCurrency($model->itemTotal); ?></div>
<div class="span-3"><?php echo CHtml::encode($model->getAttributeLabel('processingCost')); ?>:
	<?php echo Yii::app()->format->formatCurrency($model->processingCost); ?></div>
<div class="span-3"><?php echo CHtml::encode($model->getAttributeLabel('transportationCost')); ?>:
	<?php echo Yii::app()->format->formatCurrency($model->transportationCost); ?></div>
<div class="span-3"><?php echo CHtml::encode($model->getAttributeLabel('otherCost')); ?>:
	<?php echo Yii::app()->format->formatCurrency($model->otherCost); ?></div>
<div class="span-3"><?php echo CHtml::encode($model->getAttributeLabel('discount')); ?>:
	<?php echo Yii::app()->format->formatCurrency($model->discount); ?></div>
<div class="span-4 last"><?php echo '总计'; ?>:
	<?php echo Yii::app()->format->formatCurrency($model->getTotalPrice()); ?></div>
<div class="clear"></div>
<div class="span-7 item-meta">
	创建：<?php echo CHtml::encode($model->createUser->employee->fullName); ?>
	(<?php echo CHtml::encode($model->createTime); ?>)
</div>
<?php if ($model->updateUserId) { ?>
<div class="span-7 item-meta">
	最后更新：<?php echo CHtml::encode($model->createUser->employee->fullName); ?>
	(<?php echo CHtml::encode($model->createTime); ?>)
</div>
<?php } ?>
</div>
